//
//  BespeakTableViewCell.swift
//  DriverSchoolAPP
//
//  Created by Logel on 2017/5/11.
//  Copyright © 2017年 Logel. All rights reserved.
//

import UIKit

class BespeakTableViewCell: UITableViewCell {
    @IBOutlet weak var okBtn: UIButton!
    @IBOutlet weak var nameLbl: UILabel!
    @IBOutlet weak var timeLbl: UILabel!
    @IBOutlet weak var priceLbl: UILabel!
    @IBOutlet weak var statusLbl: UILabel!
    
    //点击的行数
    var selectNum:Int!
    var delegate:BespeakTableViewCellDelegate!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        okBtn.layer.cornerRadius = 5
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    @IBAction func doClick(_ sender: UIButton) {
        delegate.bespeakBtnClick(indexPath: selectNum)
    }
    
    var rs:Reservations!{
        didSet{
            nameLbl.text = rs.courseName
            timeLbl.text = rs.createTime
            switch rs.price {
            case "":
                priceLbl.isHidden = true
            default:
                priceLbl.isHidden = false
                priceLbl.text = "金额:￥\(rs.price)"
            }
            switch rs.status {
            case "init":
                statusLbl.text = "待确认"
                okBtn.isEnabled = true
                okBtn.backgroundColor = KP_MAIN_BLUE
            case "success":
                statusLbl.text = "预约成功"
                okBtn.isEnabled = true
                okBtn.backgroundColor = KP_MAIN_BLUE
            case "fail":
                statusLbl.text = "预约失败"
                okBtn.isEnabled = false
                okBtn.backgroundColor = UIColor.lightGray
            default:
                statusLbl.text = "已取消"
                okBtn.isEnabled = false
                okBtn.backgroundColor = UIColor.lightGray

            }
        
        }
    }

}

protocol BespeakTableViewCellDelegate {
    func bespeakBtnClick(indexPath:Int)
}
